package org.framework.tunte.service.jpa;

import java.util.List;

import org.framework.model.Member;
import org.framework.persist.repository.MemberRepository;
import org.framework.tunte.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.google.common.collect.Lists;

@Service("memberService")
@Repository
@Transactional
public class MemberServiceImpl implements MemberService{
	

	@Autowired
	private MemberRepository memeberRepository;

	@Transactional(readOnly=true)
	public List<Member> findAll() {
		return Lists.newArrayList(memeberRepository.findAll());
	}

	@Transactional(readOnly=true)
	public Member findById(Long id) {
		return memeberRepository.findOne(id);
	}

	public Member save(Member member) {
		return memeberRepository.save(member);
	}

	@Transactional(readOnly=true)
	public Page<Member> findAllByPage(Pageable pageable) {
		return memeberRepository.findAll(pageable);
	}

}
